package com.qiang.demo01;

import java.util.ArrayList;
import java.util.Iterator;

public class Test03 {
    public static void main(String[] args) {
        ArrayList<String> array = new ArrayList<>();
        array.add("qqq");
        array.add("www");
        array.add("eee");
        array.add("ddd");
        array.add("sss");
        array.add("ccc");
        Iterator<String> it = array.iterator();
        while (it.hasNext()) {
            String next = it.next();
            if ("sss".equals(next)) {
                it.remove();
            }
            System.out.println(next);
        }
        System.out.println("==============");
        for (String s : array) {
            System.out.println(s);
        }

        System.out.println("==============");
        String a = array.remove(2);
        System.out.println(a);

        System.out.println(array.remove(2));
    }
}
